package com.sinothk.gpserver.modules.biz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sinothk.gpserver.modules.biz.entity.RoomEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * <p>
 * 房间相关 Mapper 接口
 * </p>
 *
 * @author Liang Y.t.
 * @since 2021-08-30
 */
@Mapper
@Repository
public interface RoomMapper extends BaseMapper<RoomEntity> {

    @Select("SELECT r.*, gm.group_name FROM biz_room r LEFT JOIN biz_group_member gm ON (r.group_id = gm.group_id) WHERE gm.member_account = '${userAccount}' AND r.room_type = 0 AND r.deleted = 0")
    IPage<RoomEntity> pageForGroupMember(Page<RoomEntity> page, String userAccount);

    @Select("SELECT r.*, gm.group_name FROM biz_room r LEFT JOIN biz_group_member gm ON (r.group_id = gm.group_id) WHERE gm.member_account = '${userAccount}' AND r.room_type = 1 AND r.deleted = 0")
    IPage<RoomEntity> page7CardsForGroupMember(Page<RoomEntity> page, String userAccount);
}
